package com.onefish.toolkit.entity;

import java.lang.management.LockInfo;
import java.lang.management.MonitorInfo;
import java.lang.management.ThreadInfo;

public class ThreadTemplate {
    private long id;
    private String name;
    private String group;
    private int priority;
    private Thread.State state;
    private double cpu;
    //采样时间内的增量cpu时间
    private long deltaTime;
    //线程运行的总cup时间
    private long time;
    private boolean interrupted;
    private boolean daemon;
    /***
     * 忙碌的线程扩展字段
     */
    private long blockedTime;
    private long blockedCount;
    private long waitedTime;
    private long waitedCount;
    private LockInfo lockInfo;
    private String lockName;
    private long lockOwnerId;
    private String lockOwnerName;
    private boolean inNative;
    private boolean suspended;
    private StackTraceElement[] stackTrace;
    private MonitorInfo[] lockedMonitors;
    private LockInfo[] lockedSynchronizers;

    public ThreadTemplate() {

    }

    public ThreadTemplate(long id, String name, String group, int priority, Thread.State state, double cpu, long deltaTime, long time, boolean interrupted, boolean daemon, long blockedTime, long blockedCount, long waitedTime, long waitedCount, LockInfo lockInfo, String lockName, long lockOwnerId, String lockOwnerName, boolean inNative, boolean suspended, StackTraceElement[] stackTrace, MonitorInfo[] lockedMonitors, LockInfo[] lockedSynchronizers) {
        this.id = id;
        this.name = name;
        this.group = group;
        this.priority = priority;
        this.state = state;
        this.cpu = cpu;
        this.deltaTime = deltaTime;
        this.time = time;
        this.interrupted = interrupted;
        this.daemon = daemon;
        this.blockedTime = blockedTime;
        this.blockedCount = blockedCount;
        this.waitedTime = waitedTime;
        this.waitedCount = waitedCount;
        this.lockInfo = lockInfo;
        this.lockName = lockName;
        this.lockOwnerId = lockOwnerId;
        this.lockOwnerName = lockOwnerName;
        this.inNative = inNative;
        this.suspended = suspended;
        this.stackTrace = stackTrace;
        this.lockedMonitors = lockedMonitors;
        this.lockedSynchronizers = lockedSynchronizers;
    }

    public void setThreadInfo(ThreadInfo threadInfo) {
        if (threadInfo != null) {
            this.setLockInfo(threadInfo.getLockInfo());
            this.setLockedMonitors(threadInfo.getLockedMonitors());
            this.setLockedSynchronizers(threadInfo.getLockedSynchronizers());
            this.setLockName(threadInfo.getLockName());
            this.setLockOwnerId(threadInfo.getLockOwnerId());
            this.setLockOwnerName(threadInfo.getLockOwnerName());
            this.setStackTrace(threadInfo.getStackTrace());
            this.setBlockedCount(threadInfo.getBlockedCount());
            this.setBlockedTime(threadInfo.getBlockedTime());
            this.setInNative(threadInfo.isInNative());
            this.setSuspended(threadInfo.isSuspended());
            this.setWaitedCount(threadInfo.getWaitedCount());
            this.setWaitedTime(threadInfo.getWaitedTime());
        }
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public int getPriority() {
        return priority;
    }

    public void setPriority(int priority) {
        this.priority = priority;
    }

    public Thread.State getState() {
        return state;
    }

    public void setState(Thread.State state) {
        this.state = state;
    }

    public double getCpu() {
        return cpu;
    }

    public void setCpu(double cpu) {
        this.cpu = cpu;
    }

    public long getDeltaTime() {
        return deltaTime;
    }

    public void setDeltaTime(long deltaTime) {
        this.deltaTime = deltaTime;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public boolean isInterrupted() {
        return interrupted;
    }

    public void setInterrupted(boolean interrupted) {
        this.interrupted = interrupted;
    }

    public boolean isDaemon() {
        return daemon;
    }

    public void setDaemon(boolean daemon) {
        this.daemon = daemon;
    }

    public long getBlockedTime() {
        return blockedTime;
    }

    public void setBlockedTime(long blockedTime) {
        this.blockedTime = blockedTime;
    }

    public long getBlockedCount() {
        return blockedCount;
    }

    public void setBlockedCount(long blockedCount) {
        this.blockedCount = blockedCount;
    }

    public long getWaitedTime() {
        return waitedTime;
    }

    public void setWaitedTime(long waitedTime) {
        this.waitedTime = waitedTime;
    }

    public long getWaitedCount() {
        return waitedCount;
    }

    public void setWaitedCount(long waitedCount) {
        this.waitedCount = waitedCount;
    }

    public LockInfo getLockInfo() {
        return lockInfo;
    }

    public void setLockInfo(LockInfo lockInfo) {
        this.lockInfo = lockInfo;
    }

    public String getLockName() {
        return lockName;
    }

    public void setLockName(String lockName) {
        this.lockName = lockName;
    }

    public long getLockOwnerId() {
        return lockOwnerId;
    }

    public void setLockOwnerId(long lockOwnerId) {
        this.lockOwnerId = lockOwnerId;
    }

    public String getLockOwnerName() {
        return lockOwnerName;
    }

    public void setLockOwnerName(String lockOwnerName) {
        this.lockOwnerName = lockOwnerName;
    }

    public boolean isInNative() {
        return inNative;
    }

    public void setInNative(boolean inNative) {
        this.inNative = inNative;
    }

    public boolean isSuspended() {
        return suspended;
    }

    public void setSuspended(boolean suspended) {
        this.suspended = suspended;
    }

    public StackTraceElement[] getStackTrace() {
        return stackTrace;
    }

    public void setStackTrace(StackTraceElement[] stackTrace) {
        this.stackTrace = stackTrace;
    }

    public MonitorInfo[] getLockedMonitors() {
        return lockedMonitors;
    }

    public void setLockedMonitors(MonitorInfo[] lockedMonitors) {
        this.lockedMonitors = lockedMonitors;
    }

    public LockInfo[] getLockedSynchronizers() {
        return lockedSynchronizers;
    }

    public void setLockedSynchronizers(LockInfo[] lockedSynchronizers) {
        this.lockedSynchronizers = lockedSynchronizers;
    }

}
